package com.gykfbxxh.imovie.utils;

import android.text.Html;
import android.widget.TextView;

import com.app.utils.pulltorefresh.ILoadingLayout;
import com.app.utils.pulltorefresh.PullToRefreshBase;
import com.app.utils.pulltorefresh.PullToRefreshListView;

/**
 * 公用的修改控件的方法封装
 * Created by xuxinghai on 2016/7/15.
 */
public class AppViewUtils {


    /**
     * 设置上拉下拉控件的刷新文字
     * @param pullToRefreshListView
     */
	public static void initPullToRefreshListView(final PullToRefreshListView pullToRefreshListView){
		pullToRefreshListView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
//		pullToRefreshListView.setMode(PullToRefreshBase.Mode.BOTH);
		/**
         * 已经设置自动加载下一页
         * 如果设置了setOnScrollListener监听，那么setOnLastItemVisibleListener(自动加 载)将不起作用
         */
		pullToRefreshListView.setOnLastItemVisibleListener(new PullToRefreshBase.OnLastItemVisibleListener() {

			@Override
			public void onLastItemVisible() {


				if (pullToRefreshListView.isRefreshing()) {
					return;
				}
				if (pullToRefreshListView.getOnRefreshListener2() != null) {
					pullToRefreshListView.getOnRefreshListener2().onPullUpToRefresh(pullToRefreshListView);
				}
				pullToRefreshListView.showFootView();
			}
		});

		ILoadingLayout iLoadingLayout=pullToRefreshListView.getLoadingLayoutProxy(true, false);
		iLoadingLayout.setPullLabel("");// 刚下拉时，显示的提示
		iLoadingLayout.setRefreshingLabel("");// 刷新时
		iLoadingLayout.setReleaseLabel("");// 下来达到一定距离时，显示的提示

		ILoadingLayout iLoadingLayout2=pullToRefreshListView.getLoadingLayoutProxy(false, true);
		iLoadingLayout2.setPullLabel("");// 刚上拉时，显示的提示
		iLoadingLayout2.setRefreshingLabel("");// 刷新时
		iLoadingLayout2.setReleaseLabel("");// 上拉达到一定距离时，显示的提示
//		String label1 = DateUtils.formatDateTime(AppApplication.getInstance(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);
		iLoadingLayout.setLastUpdatedLabel("");//去除刷新时间
	}



	/**
	 * 把html语言设置到textview中
	 *
	 * @param textView
	 * @param s
	 */
	public static void setTexthtml(TextView textView, String s) {
		textView.setText(Html.fromHtml(s));
	}


}
